import config from "@/config"
import http from "@/utils/request"


//付款管理
export default {
  getPayment: {
    url: `${config.API_URL}/payment/list`,
    name: "获取付款管理列表",
    get: function (data) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  getPaymentById: {
    url: `${config.API_URL}/payment/listById`,
    name: "获取详情",
    get: function (data) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  addPayment: {
    url: `${config.API_URL}/payment/add`,
    name: "添加付款",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  updatePayment: {
    url: `${config.API_URL}/payment/update`,
    name: "修改付款",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  deletePayment: {
    url: `${config.API_URL}/payment/delete`,
    name: "删除",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  confirmPayment: {
    url: `${config.API_URL}/payment/paymentOperate`,
    name: "确认付款",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  getCountMoney: {
    url: `${config.API_URL}/payment/listStatistics`,
    name: "统计金额",
    get: function (data) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  getVendorList: {
    url: `${config.API_URL}/payment/arrearsMoney`,
    name: "获取需要付款的供应商",
    get: function (data) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  getVendorOrders: {
    url: `${config.API_URL}/payment/vendorOrders`,
    name: "获取供应商源单",
    get: function (data) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
}